<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #box{
          width: 500px;
          height: 400px;
          background-color: orange;
        }
        span{
            display:block;
            float:left;
            width: 60px;
            height: 100px;
            margin-right:10px;
            font-size: 50px;
            text-align:center;
            line-height:100px;
        }
        .indent-2 {
          text-indent: 2em;
        }
        .right {
          float:right;
        }
        .clear {
          clear:both;
          float:right;
        }
       
    </style>
</head>
<body>    
   <div id="box">
	  <div>昵称:<input type="text" id="name"></div><br>
    <div class="indent-2"><textarea rows="14" cols="50"></textarea></div>
    <form action="/action_page.php">
    <div>
      <div class="right">
        <input type="checkbox" id="box1" name="box1" value="匿名">
        <label for="box1"> 匿名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><br>
      </div> 
       <div class="clear">
         <input type="button" value = "发表" id = "submit">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;&nbsp;&nbsp;
      </div>
      <div id="board"></div>
    </div>
     
    </form>
	  </div>
  

    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script>
    var $nickName = $("#name")
    var $note = $("textarea")  
    var $submit = $("#submit")
    var $board = $("#board")

    $submit.click(function(){
          if ($nickName.val() === "" || $note.val() === "")
              alert("昵称或内容不能为空")
          else
              {
                  if ($("#box1").prop("checked"))
                  {
                    $board.append("路人甲: "+ new Date().getHours()+":"+ new Date().getMinutes()  +":"+ new Date().getSeconds())
                    var txt2=$("<p></p>").text($note.val())
                    $board.append(txt2)
                    
                  }
                  else
                  {
                    $board.append($nickName.val()+ new Date().getHours()+":"+ new Date().getMinutes()  +":"+ new Date().getSeconds())
                    var txt2=$("<p></p>").text($note.val())
                    $board.append(txt2)
                  }
              }
          $note.val("")
          $nickName.val("")
    })
    
   
       
    </script>
</body>
</html>